home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Champak 29
/
Volume 29 - JOGO DISK .iso
/
Games
/
jungle_adventure.swf
/
scripts
/
__Packages
/
GamePlayer.as
< prev
next >
Wrap
Text File
|
2006-11-29
|
2KB
|
96 lines
class GamePlayer
{
var score = 0;
var health = 1;
var lives = 3;
var shield = 0;
var fuel = 0;
var left = false;
var right = false;
var up = false;
var down = false;
var jump = false;
var action = false;
function GamePlayer()
{
this.initialize();
this.lives = !_global.VR_ON_LIVES ? 3 : 5;
}
function initialize()
{
Key.addListener(this);
}
function destroy()
{
Key.removeListener(this);
}
function setControl(obj)
{
this.control.deactivate();
this.control.active = false;
this.control = obj;
obj.controller = this;
obj.active = true;
obj.activate();
}
function shiftScore(value)
{
this.score += value;
}
function update(elapsed)
{
this.control.update(elapsed);
this.clearKeys();
}
function onKeyDown()
{
if(this.lastKey == (this.lastKey = Key.getCode()))
{
return undefined;
}
switch(this.lastKey)
{
case 37:
this.left = true;
break;
case 38:
this.up = true;
break;
case 39:
this.right = true;
break;
case 40:
this.down = true;
break;
case 32:
this.jump = true;
break;
case 68:
this.action = true;
}
}
function onKeyUp()
{
switch(Key.getCode())
{
case 37:
this.left = false;
break;
case 38:
this.up = false;
break;
case 39:
this.right = false;
break;
case 40:
this.down = false;
}
this.lastKey = 0;
}
function clearKeys()
{
this.jump = false;
this.action = false;
}
}